package com.ruoyi.web.controller.devicetemperature;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.DeviceTemperature;
import com.ruoyi.yanjing.service.IDeviceTemperatureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 温度日志Controller
 * 
 * @author whz
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/yanjing/temperature")
public class DeviceTemperatureController extends BaseController
{
    @Autowired
    private IDeviceTemperatureService deviceTemperatureService;
    /**
     * 查询温度日志列表先气功
     */
//    @PreAuthorize("@ss.hasPermi('yanjing:temperature:list')")
//    @ApiOperation("查询温度日志列表")
    @GetMapping("/queryDeviceTemperatureList")
    public TableDataInfo queryDeviceTemperatureList(DeviceTemperature deviceTemperature)
    {
        startPage();
        List<DeviceTemperature> list = deviceTemperatureService.deviceTemperatureList(deviceTemperature);
        return getDataTable(list);
    }


    /**
     * 查询温度日志列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:selectAllTemperatureList')")
    @GetMapping("/selectAllTemperatureList")
    public AjaxResult selectAllTemperatureList(DeviceTemperature deviceTemperature)
    {
        return success(deviceTemperatureService.selectAllTemperatureList(deviceTemperature));
    }


    /**
     * 查询温度日志列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceTemperature deviceTemperature)
    {
        startPage();
        List<DeviceTemperature> list = deviceTemperatureService.selectDeviceTemperatureList(deviceTemperature);
        return getDataTable(list);
    }

    /**
     * 导出温度日志列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:export')")
    @Log(title = "温度日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceTemperature deviceTemperature)
    {
        List<DeviceTemperature> list = deviceTemperatureService.selectDeviceTemperatureList(deviceTemperature);
        ExcelUtil<DeviceTemperature> util = new ExcelUtil<DeviceTemperature>(DeviceTemperature.class);
        util.exportExcel(response, list, "温度日志数据");
    }

    /**
     * 获取温度日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(deviceTemperatureService.selectDeviceTemperatureById(id));
    }

    /**
     * 新增温度日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:add')")
    @Log(title = "温度日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceTemperature deviceTemperature)
    {
        return toAjax(deviceTemperatureService.insertDeviceTemperature(deviceTemperature));
    }

    /**
     * 新增温度日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:insertBatch')")
    @Log(title = "批量新增温度日志", businessType = BusinessType.INSERT)
    @PostMapping(value = "/insertBatch")
    public AjaxResult insertBatch(@RequestBody List<DeviceTemperature> deviceTemperatureList)
    {
        return toAjax(deviceTemperatureService.insertBatch(deviceTemperatureList));
    }

    /**
     * 修改温度日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:edit')")
    @Log(title = "温度日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceTemperature deviceTemperature)
    {
        return toAjax(deviceTemperatureService.updateDeviceTemperature(deviceTemperature));
    }

    /**
     * 删除温度日志
     */
    @PreAuthorize("@ss.hasPermi('yanjing:temperature:remove')")
    @Log(title = "温度日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deviceTemperatureService.deleteDeviceTemperatureByIds(ids));
    }
}
